package com.android.webttest.dao;


import androidx.room.Dao;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Update;


import com.android.webttest.model.tableModel.SearchHistoryRecord;

import java.util.List;

@Dao
public interface SearchHistoryDao {

    @Insert
    void insert(SearchHistoryRecord record);

    @Query("SELECT * FROM search_history ORDER BY search_count DESC, update_time DESC")
    List<SearchHistoryRecord> getAll();

    @Query("DELETE FROM search_history")
    void deleteAll();

//    @Query("SELECT * FROM SearchHistoryRecord WHERE query = :query LIMIT 1")
//    SearchHistoryRecord findByQuery(String query);

    @Query("SELECT * FROM search_history WHERE `query` = :query LIMIT 1")
    SearchHistoryRecord findByQuery(String query);


    @Update
    void update(SearchHistoryRecord record);
}
